package com.ruoyi.qiuyue.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.qiuyue.domain.MusicUser;
import com.ruoyi.qiuyue.service.IMusicUserService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 秋月用户Controller
 * 
 * @author ruoyi
 * @date 2024-05-15
 */
@RestController
@RequestMapping("/music/musicuser")
public class MusicUserController extends BaseController
{
    @Autowired
    private IMusicUserService musicUserService;

    /**
     * 查询秋月用户列表
     */
    @PreAuthorize("@ss.hasPermi('music:musicuser:list')")
    @GetMapping("/list")
    public TableDataInfo list(MusicUser musicUser)
    {
        startPage();
        List<MusicUser> list = musicUserService.selectMusicUserList(musicUser);
        return getDataTable(list);
    }

    /**
     * 导出秋月用户列表
     */
    @PreAuthorize("@ss.hasPermi('music:musicuser:export')")
    @Log(title = "秋月用户", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MusicUser musicUser)
    {
        List<MusicUser> list = musicUserService.selectMusicUserList(musicUser);
        ExcelUtil<MusicUser> util = new ExcelUtil<MusicUser>(MusicUser.class);
        util.exportExcel(response, list, "秋月用户数据");
    }

    /**
     * 获取秋月用户详细信息
     */
    @PreAuthorize("@ss.hasPermi('music:musicuser:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(musicUserService.selectMusicUserById(id));
    }

    /**
     * 新增秋月用户
     */
    @PreAuthorize("@ss.hasPermi('music:musicuser:add')")
    @Log(title = "秋月用户", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MusicUser musicUser)
    {
        return toAjax(musicUserService.insertMusicUser(musicUser));
    }

    /**
     * 修改秋月用户
     */
    @PreAuthorize("@ss.hasPermi('music:musicuser:edit')")
    @Log(title = "秋月用户", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MusicUser musicUser)
    {
        return toAjax(musicUserService.updateMusicUser(musicUser));
    }

    /**
     * 删除秋月用户
     */
    @PreAuthorize("@ss.hasPermi('music:musicuser:remove')")
    @Log(title = "秋月用户", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(musicUserService.deleteMusicUserByIds(ids));
    }
}
